package com.learn.lessons.helloworld.commons;

/**
 * @BelongsProject: HelloWorld
 * @BelongsPackage: com.learn.lessons.helloworld.commons
 * @Author: guodf
 * @CreateTime: 2022-11-03  13:32
 * @Description: 文件类型枚举类
 * @Version: 1.0.0
 */
public enum FileTypeResolveEnum {

    FILE_DEFAULT_RESOLVE(0,"word"),
    FILE_A_RESOLVE(1,"excel"),
    FILE_B_RESOLVE(2,"png"),
    ;

    private Integer code;

    private String name;

    FileTypeResolveEnum(Integer code, String name){
        this.code=code;
        this.name=name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据code获取msg
     */
    public static String getMsgByCode(Integer code){
        for (FileTypeResolveEnum value : FileTypeResolveEnum.values()) {
            if(value.getCode().equals(code)){
                return value.getName();
            }
        }
        return null;
    }


    /**
     * 根据code获取FileTypeResolveEnum
     */
    public static FileTypeResolveEnum getEventEnumByCode(Integer code){
        for (FileTypeResolveEnum value : FileTypeResolveEnum.values()) {
            if(value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }
}
